package com.yx.front.controller;

import com.yx.front.annotation.AnonymousAccess;
import com.yx.front.config.global.CommonResult;
import com.yx.front.manager.SysUserManager;
import com.yx.front.model.base.BaseParam;
import com.yx.front.model.param.SysUserParam;
import com.yx.front.model.vo.AdviceFriendVo;
import com.yx.front.model.vo.SysUserVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author YangXiong
 */
@Slf4j
@Api(tags = "用户管理控制器")
@RequestMapping("/sys-user")
@RestController
public class SysUserController {
    @Resource
    private SysUserManager sysUserManager;

    @GetMapping("/detail")
    @ApiOperation("根据用户名获取用户详情")
    public CommonResult<SysUserVo> getUserByName(String name) {
        log.info("SysUserController info getUserByName userName={}", name);
        return sysUserManager.getUserByName(name);
    }

    @PostMapping("/friend/list")
    @AnonymousAccess
    @ApiOperation("好友推荐")
    public CommonResult<List<AdviceFriendVo>> getFriendList(@RequestBody BaseParam param){
        return sysUserManager.getFriendList(param);
    }

    @PostMapping("/update")
    @ApiOperation("更新用户信息")
    public CommonResult<Map<String,String>> updateUser(@RequestBody SysUserParam user){
        return sysUserManager.updateUser(user);
    }
}
